<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl" />
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl" />
    <div class="row">
        <div class="col-sm-3">
        <#--声明变量-->
            <#assign menu="student"/>
            <#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">学生管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <a class="btn btn-success inputBtn">
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </a>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>编号</th>
                    <th>学生姓名</th>
                    <th>账户余额</th>
                    <th>注册时间</th>
                    <th>年龄</th>
                    <th>性别</th>
                    <th>电话</th>
                    <th>qq</th>
                    <th>email</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index+1}</td>
                        <td>${entity.username}</td>
                        <td>${entity.usermoney}</td>
                        <td>${entity.regtime?string("dd.MM.yyyy HH:mm:ss")}</td>
                        <td>${entity.age}</td>
                        <td>${entity.gendarName}</td>
                        <td>${entity.tel}</td>
                        <td>${entity.qq}</td>
                        <td>${entity.email}</td>
                        <td>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl" />
        </div>
    </div>
</div>
<#--学生编辑的模态框-->
<div class="modal fade" id="departmentModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        <#--模态框的头部-->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="departmentModal">编辑员工信息</h4>
            </div>
        <#--模态框的正文-->
            <div class="modal-body">
                <form class="form-horizontal" action="/department/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" name="id">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">学生名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name"
                                   placeholder="请输入学生的名称">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label">学生编号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sn"
                                   placeholder="请输入学生编号">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default glyphicon glyphicon-remove-sign" data-dismiss="modal">关闭
                </button>
                <button type="button" class="glyphicon glyphicon-ok-sign btn btn-primary saveBtn ">保存
                </button>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $(".inputBtn").click(function () {
            //清空模态框
            $("#editForm").val("");
            //拿到当前按钮的json数据
            var json = $(this).data("json");
            //只有具有json时才会回显数据
            if (json) {
                $("#editForm input[name='id']").val(json.id);
                $("#editForm input[name='name']").val(json.name);
                $("#editForm input[name='sn']").val(json.sn);
            }
            $("#departmentModal").modal("show");
        });
        //异步提交数据
        $(".saveBtn").click(function () {
            $("#editForm").ajaxSubmit(function (data) {
                if (data.success) {
                    reload();
                }
            })
        })
        //删除数据
        $(".deleteBtn").click(function () {
            var url = $(this).data("url");
            $.messager.confirm("温馨提示", "删除后无法还原,是否确认删除", function () {
                $.get(url, function (data) {
                    if (data.success) {
                        reload();
                    } else {
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })
        });
    })
</script>
</body>
</html>